package com.spider.job;

import com.spider.service.KubazhaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 库巴扎价格修改是通过上传商品是原价，然后调用特殊价格接口，再把折扣价上传上去。
 *
 */
@Component
public class KubazhaJobTask {
    private final Logger logger = LoggerFactory.getLogger(KubazhaJobTask.class);

    @Autowired
    KubazhaService kubazhaService;
    /**
     * 库巴扎新增库存接口
     */
    //每天14点15执行
    //@Scheduled(cron = "0 0/2 * * * ? ")
    //@Scheduled(cron = "0/20 * * * * ?")  20秒一次
    //@Scheduled(cron = "0 25 14,18 * * ?")
    public void stockInsertHandle() {
        logger.info("库巴扎新产品库存推送开始：日期"+new Date().toString());
        kubazhaService.stockInsert(null);
        logger.info("库巴扎新产品库存推送结束：日期"+new Date().toString());
    }

    /**
     * 库巴扎价格修改接口
     */
    //@Scheduled(cron = "0 49 14,18 * * ?")
    public void priceUpdateHandle() {
        logger.info("库巴扎价格推送开始：日期"+new Date().toString());
        kubazhaService.updatePrice(null);
        logger.info("库巴扎价格推送结束：日期"+new Date().toString());
    }

    /**
     * 库巴扎库存修改接口
     */
    //@Scheduled(cron = "0 47 14,18 * * ?")
    public void updateStockHandle() {
        logger.info("库巴扎库存推送开始：日期"+new Date().toString());
        kubazhaService.updateStock(null);
        logger.info("库巴扎库存推送结束：日期"+new Date().toString());
    }

    /**
     * 库巴扎下架产品接口
     */
    //@Scheduled(cron = "0 25 14,18 * * ?")
    public void deleteProductHandle() {
        logger.info("库巴扎下架产品推送开始：日期"+new Date().toString());
        kubazhaService.deleteProduct(null);
        logger.info("库巴扎下架产品推送结束：日期"+new Date().toString());
    }
}
